/*package com.example.activity;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.widget.ImageView;
import com.ipcamer.demo.AddCameraActivity;
import com.ipcamer.demo.BridgeService;
import com.ipcamer.demo.BridgeService.PlayInterface;
import com.util.L;
import java.io.PrintStream;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Iterator;
import object.p2pipcam.nativecaller.NativeCaller;
import com.example.application.Appdata;
import com.example.util.ShowHandle;

public class BaseActivity extends AddCameraActivity
{
  private static final String STR_DID = "did";
  private static final String STR_MSG_PARAM = "msgparam";
  private Handler PPPPMsgHandler = new Handler()
  {
    public void handleMessage(Message paramAnonymousMessage)
    {
      Bundle localBundle = paramAnonymousMessage.getData();
      int i = localBundle.getInt("msgparam");
      int j = paramAnonymousMessage.what;
      String str = localBundle.getString("did");
      Log.i("info", "ppp" + j);
      switch (j)
      {
      default:
        Log.e("eid", BaseActivity.this.getString(BaseActivity.this.resid) + BaseActivity.this.postion2);
        ((Video)Appdata.arrayList.get(BaseActivity.this.postion2)).setState(BaseActivity.this.getString(BaseActivity.this.resid));
        BaseActivity.access$302(BaseActivity.this, 10);
        new Thread(BaseActivity.this.video_run).start();
        return;
      case 0:
      }
      switch (i)
      {
      default:
        BaseActivity.access$102(BaseActivity.this, 2131296590);
      case 0:
      case 3:
      case 4:
      case 1:
      case 5:
      case 2:
      case 6:
      case 7:
      }
      while (true)
      {
        if (i == 2)
          NativeCaller.PPPPGetSystemParams(str, 4);
        if ((i != 5) && (i != 3) && (i != 6) && (i != 7))
          break;
        NativeCaller.StopPPPP(str);
        break;
        BaseActivity.access$102(BaseActivity.this, 2131296585);
        continue;
        BaseActivity.access$102(BaseActivity.this, 2131296583);
        continue;
        BaseActivity.access$102(BaseActivity.this, 2131296586);
        continue;
        BaseActivity.access$102(BaseActivity.this, 2131296587);
        continue;
        BaseActivity.access$102(BaseActivity.this, 2131296588);
        continue;
        BaseActivity.access$102(BaseActivity.this, 2131296589);
        continue;
        BaseActivity.access$102(BaseActivity.this, 2131296396);
        continue;
        BaseActivity.access$102(BaseActivity.this, 2131296584);
      }
    }
  };
  protected Appdata Appdata;
  protected Bitmap bitmap;
  private Runnable curRun = new Runnable()
  {
    public void run()
    {
      try
      {
        BaseActivity.this.StartCameraPPPP();
        Thread.sleep(10000L);
        return;
      }
      catch (InterruptedException localInterruptedException)
      {
        localInterruptedException.printStackTrace();
      }
    }
  };
  private Intent intentbrod = null;
  protected boolean isHaveCamra = false;
  protected boolean isInitFinish = false;
  protected boolean isOnVideo = false;
  protected boolean isTakepic = false;
  protected boolean is_video_run = true;
  protected Bitmap mBmp;

  @SuppressLint({"HandlerLeak"})
  private Handler mHandler = new Handler()
  {
    public void handleMessage(Message paramAnonymousMessage)
    {
      String str = paramAnonymousMessage.getData().getString("did");
      switch (paramAnonymousMessage.what)
      {
      default:
      case 1:
      case 2:
      }
      while (true)
      {
        return;
        L.Debug("mHandler 1", "");
        byte[] arrayOfByte = new byte[2 * (BaseActivity.this.nVideoWidths * BaseActivity.this.nVideoHeights)];
        if (BaseActivity.this.videodata != null)
          L.Debug("mHandler videodata run", "");
        L.Debug("mHandler videodata null", "");
        NativeCaller.YUV4202RGB565(BaseActivity.this.videodata, arrayOfByte, BaseActivity.this.nVideoWidths, BaseActivity.this.nVideoHeights);
        L.Debug("mHandler 1_2", "");
        ByteBuffer localByteBuffer = ByteBuffer.wrap(arrayOfByte);
        BaseActivity.this.mBmp = Bitmap.createBitmap(BaseActivity.this.nVideoWidths, BaseActivity.this.nVideoHeights, Bitmap.Config.RGB_565);
        BaseActivity.this.mBmp.copyPixelsFromBuffer(localByteBuffer);
        BaseActivity.this.bitmap = Bitmap.createScaledBitmap(BaseActivity.this.mBmp, BaseActivity.this.nVideoWidths, BaseActivity.this.nVideoHeights, true);
        int i = 0;
        Matrix localMatrix2 = new Matrix();
        localMatrix2.postScale(1.0F, 1.0F);
        BaseActivity.this.bitmap = Bitmap.createBitmap(BaseActivity.this.bitmap, 0, 0, BaseActivity.this.bitmap.getWidth(), BaseActivity.this.bitmap.getHeight(), localMatrix2, true);
        L.Debug("bitmap.getWidth():" + BaseActivity.this.bitmap.getWidth() + ",bitmap.getHeight():" + BaseActivity.this.bitmap.getHeight(), "");
        Iterator localIterator2 = BaseActivity.this.onlinelist.iterator();
        while (localIterator2.hasNext())
        {
          if (str.equals(((Video)localIterator2.next()).getUid()))
            BaseActivity.this.video_iv.setImageBitmap(BaseActivity.this.bitmap);
          i++;
        }
        L.Debug("mHandler 1end", "");
        return;
        L.Debug("mHandler 2", "");
        BaseActivity.this.mBmp = BitmapFactory.decodeByteArray(BaseActivity.this.videodata, 0, BaseActivity.this.videoDataLen);
        BaseActivity.this.nVideoWidth = BaseActivity.this.mBmp.getWidth();
        BaseActivity.this.nVideoHeight = BaseActivity.this.mBmp.getHeight();
        Matrix localMatrix1 = new Matrix();
        localMatrix1.postScale(0.5F, 0.5F);
        BaseActivity.this.mBmp = Bitmap.createBitmap(BaseActivity.this.mBmp, 0, 0, BaseActivity.this.mBmp.getWidth(), BaseActivity.this.mBmp.getHeight(), localMatrix1, true);
        Iterator localIterator1 = BaseActivity.this.onlinelist.iterator();
        while (localIterator1.hasNext())
          if (str.equals(((Video)localIterator1.next()).getUid()))
            BaseActivity.this.video_iv.setImageBitmap(BaseActivity.this.mBmp);
      }
    }
  };
  Message msg;
  protected int nVideoHeight = 0;
  public int nVideoHeights = 0;
  protected int nVideoWidth = 0;
  public int nVideoWidths = 0;
  protected ArrayList<Video> onlinelist = new ArrayList();
  protected SurfaceHolder playHolder = null;
  protected SurfaceView playSurface = null;
  protected PlayVideo playVideo = null;
  private int postion2;
  private int resid = 2131296585;
  protected String roomId = "";
  protected ShowHandle showHandle;
  private int streamType = 3;
  protected int videoDataLen = 0;
  protected ImageView video_iv;
  private Runnable video_run = new Runnable()
  {
    public void run()
    {
      L.Debug("isOnVideo", "" + BaseActivity.this.isOnVideo);
      while (BaseActivity.this.is_video_run)
      {
        try
        {
          if ((!BaseActivity.this.getString(BaseActivity.this.resid).equals("鍦ㄧ嚎")) || (BaseActivity.this.isOnVideo) || (Appdata.arrayList.isEmpty()))
            break label233;
          Iterator localIterator = Appdata.arrayList.iterator();
          while (localIterator.hasNext())
          {
            Video localVideo = (Video)localIterator.next();
            if (("鍦ㄧ嚎".equals(localVideo.getState())) && (!BaseActivity.this.isOnVideo) && (BaseActivity.this.roomId.equals(localVideo.getRoomId())))
            {
              new Video();
              Log.e("璁剧疆寮�鍚棰戞暟鎹祦 --->a", localVideo.getState());
              Log.e("璁剧疆寮�鍚棰戞暟鎹祦 roomid--->a", localVideo.getRoomId());
              BaseActivity.this.onlinelist.add(localVideo);
              NativeCaller.StartPPPPLivestream(localVideo.getUid(), 10);
            }
          }
        }
        catch (InterruptedException localInterruptedException)
        {
          localInterruptedException.printStackTrace();
        }
        continue;
        label233: Thread.sleep(1000L);
      }
    }
  };
  protected byte[] videodata = null;

  private void InitParams()
  {
    Log.e("init", "init");
    Intent localIntent = new Intent();
    localIntent.setClass(this, BridgeService.class);
    startService(localIntent);
    new Thread(new Runnable()
    {
      // ERROR //
      public void run()
      {
        // Byte code:
        //   0: aload_0
        //   1: monitorenter
        //   2: ldc 24
        //   4: invokestatic 30	object/p2pipcam/nativecaller/NativeCaller:PPPPInitial	(Ljava/lang/String;)V
        //   7: new 32	java/util/Date
        //   10: dup
        //   11: invokespecial 33	java/util/Date:<init>	()V
        //   14: invokevirtual 37	java/util/Date:getTime	()J
        //   17: pop2
        //   18: invokestatic 41	object/p2pipcam/nativecaller/NativeCaller:PPPPNetworkDetect	()I
        //   21: pop
        //   22: aload_0
        //   23: monitorexit
        //   24: return
        //   25: astore_2
        //   26: aload_0
        //   27: monitorexit
        //   28: aload_2
        //   29: athrow
        //   30: astore_1
        //   31: goto -9 -> 22
        //
        // Exception table:
        //   from	to	target	type
        //   2	22	25	finally
        //   2	22	30	java/lang/Exception
      }
    }).start();
  }

  private void StartCameraPPPP()
  {
    BridgeService.setIpcamClientInterface(this);
    NativeCaller.Init();
    Log.e("BaseActivity a", "a");
    Iterator localIterator = Appdata.arrayList.iterator();
    while (localIterator.hasNext())
    {
      Video localVideo = (Video)localIterator.next();
      if (this.roomId.equals(localVideo.getRoomId()))
      {
        int i = NativeCaller.StartPPPP(localVideo.getUid(), localVideo.getVedioName(), localVideo.getPassword());
        System.out.println("StartPPPP uid:" + localVideo.getUid());
        System.out.println("StartPPPP pwd:" + localVideo.getPassword());
        System.out.println("StartPPPP result:" + i);
      }
    }
    System.out.println("BaseActivity StartPPPP result:");
  }

  public void BSMsgNotifyData(String paramString, int paramInt1, int paramInt2)
  {
    L.Debug("CurActivity BSMsgNotifyData", "");
    L.Debug("CurActivity type", "" + paramInt1);
    L.Debug("CurActivity param", "" + paramInt2);
    L.Debug("CurActivity* roomId", "" + this.roomId);
    for (int i = 0; i < Appdata.arrayList.size(); i++)
    {
      String str1 = "CurActivity** BS room_id_" + i;
      StringBuilder localStringBuilder1 = new StringBuilder().append("");
      L.Debug(str1, ((Video)Appdata.arrayList.get(i)).getRoomId());
      L.Debug("CurActivity** did", "" + paramString);
      String str2 = "CurActivity** uid" + i;
      StringBuilder localStringBuilder2 = new StringBuilder().append("");
      L.Debug(str2, ((Video)Appdata.arrayList.get(i)).getUid());
      if (((Video)Appdata.arrayList.get(i)).getUid().equals(paramString))
      {
        String str3 = this.roomId;
        if (str3.equals(((Video)Appdata.arrayList.get(i)).getRoomId()))
        {
          this.postion2 = i;
          Log.d("BSMsgNotifyData", "type:" + paramInt1 + " param:" + paramInt2);
          Bundle localBundle = new Bundle();
          this.msg = this.PPPPMsgHandler.obtainMessage();
          this.msg.what = paramInt1;
          localBundle.putInt("msgparam", paramInt2);
          localBundle.putString("did", paramString);
          this.msg.setData(localBundle);
          this.PPPPMsgHandler.sendMessage(this.msg);
        }
      }
    }
  }

  public void getVedioList()
  {
    this.showHandle = new ShowHandle(this, "it");
    this.showHandle.OpenDb();
    L.Debug("showHandle.getDevice()", "" + this.showHandle.getDevice());
    Appdata.arrayList = this.showHandle.getDevice();
    this.showHandle.CloseDb();
  }

  public boolean isHaveCamra()
  {
    ArrayList localArrayList = new ArrayList();
    localArrayList.clear();
    Iterator localIterator1 = Appdata.arrayList.iterator();
    while (localIterator1.hasNext())
    {
      Video localVideo2 = (Video)localIterator1.next();
      if (this.roomId.equals(localVideo2.getRoomId()))
        localArrayList.add(localVideo2);
    }
    Log.e("room_video roomId", "" + this.roomId);
    Iterator localIterator2 = localArrayList.iterator();
    while (localIterator2.hasNext())
    {
      Video localVideo1 = (Video)localIterator2.next();
      if ((localVideo1.getDeviceType().equals("SX")) && (!localVideo1.getUid().equals("")))
      {
        Log.e("room_video.getUid()", "" + localVideo1.getUid());
        return true;
      }
    }
    return false;
  }

  public void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    this.isInitFinish = false;
    this.Appdata = ((Appdata)getApplicationContext());
    this.roomId = getIntent().getStringExtra("roomId");
    getVedioList();
    this.isOnVideo = false;
    this.isHaveCamra = isHaveCamra();
    InfoActivity.isRunVideo = getSharedPreferences("inteligenttools", 0).getBoolean("playVedio", false);
    InitParams();
    BridgeService.setAddCameraInterface(this);
    this.playVideo = new PlayVideo();
    BridgeService.setPlayInterface(this.playVideo);
  }

  protected void onDestroy()
  {
    super.onDestroy();
    NativeCaller.Free();
  }

  protected void onResume()
  {
    super.onResume();
    this.is_video_run = true;
    Log.e("isHaveCamra", "" + this.isHaveCamra);
    if ((Appdata.arrayList.size() != 0) && (this.isHaveCamra) && (InfoActivity.isRunVideo))
      new Thread(this.curRun).start();
  }

  protected void onStop()
  {
    this.is_video_run = false;
    NativeCaller.StopSearch();
    super.onStop();
  }

  protected class PlayVideo
    implements BridgeService.PlayInterface
  {
    protected PlayVideo()
    {
    }

    public void callBaceVideoData(String paramString, byte[] paramArrayOfByte, int paramInt1, int paramInt2, int paramInt3, int paramInt4)
    {
      L.Debug("callBaceVideoData run", "");
      Log.d("info", "Call VideoData...h264Data: " + paramString + paramInt1 + " len: " + paramInt2 + " videobuf len: " + paramArrayOfByte.length + "width==" + BaseActivity.this.nVideoWidth + "height==" + BaseActivity.this.nVideoHeight);
      BaseActivity.this.videodata = paramArrayOfByte;
      BaseActivity.this.videoDataLen = paramInt2;
      BaseActivity.this.nVideoWidths = paramInt3;
      BaseActivity.this.nVideoHeights = paramInt4;
      L.Debug("callBaceVideoData run did", "" + paramString);
      Bundle localBundle = new Bundle();
      localBundle.putString("did", paramString);
      Message localMessage = new Message();
      localMessage.setData(localBundle);
      if (paramInt1 == 1)
      {
        Log.i("info", "h264Data....");
        if (BaseActivity.this.isTakepic)
        {
          BaseActivity.this.isTakepic = false;
          byte[] arrayOfByte = new byte[2 * (paramInt3 * paramInt4)];
          NativeCaller.YUV4202RGB565(paramArrayOfByte, arrayOfByte, paramInt3, paramInt4);
          ByteBuffer localByteBuffer = ByteBuffer.wrap(arrayOfByte);
          BaseActivity.this.mBmp = Bitmap.createBitmap(paramInt3, paramInt4, Bitmap.Config.RGB_565);
          BaseActivity.this.mBmp.copyPixelsFromBuffer(localByteBuffer);
        }
      }
      for (localMessage.what = 1; ; localMessage.what = 2)
      {
        BaseActivity.this.isOnVideo = true;
        if (BaseActivity.this.isInitFinish)
          BaseActivity.this.mHandler.sendMessage(localMessage);
        return;
        Log.i("info", "MJPEG....");
      }
    }

    public void callBackAudioData(byte[] paramArrayOfByte, int paramInt)
    {
    }

    public void callBackCameraParamNotify(String paramString, int paramInt1, int paramInt2, int paramInt3, int paramInt4, int paramInt5, int paramInt6)
    {
    }

    public void callBackH264Data(byte[] paramArrayOfByte, int paramInt1, int paramInt2)
    {
    }

    public void callBackMessageNotify(String paramString, int paramInt1, int paramInt2)
    {
    }
  }
}
*/